﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DbMapping;
using System.Data;
using VideoCache.Server.Model;

namespace VideoCache.Server.DAL
{
    public partial class SiteDAL
    {
        public static SiteInfo[] GetAlbumSites(int albumId)
        {
            string sql = "SELECT * FROM t_site WHERE Id IN (SELECT DISTINCT SiteId FROM t_episode WHERE AlbumId=@AlbumId)";

            IDataParameter[] parmList = { DbAccess.CreateParameter("AlbumId", albumId) };

            DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, parmList);

            List<SiteInfo> list = new List<SiteInfo>();

            foreach (DataRow row in dt.Rows)
            {
                list.Add(GetModel(row));
            }

            return list.ToArray();
        }
    }
}
